/*
 * Copyright (c) 2018 22420103@QQ.COM 版权所有
 */
package com.lehe.service.impl;

import com.lehe.dao.WhiteUserDao;
import com.lehe.entry.BaseResponse;
import com.lehe.entry.SqlParameterDto;
import com.lehe.entry.WhiteUserDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 白名单服务
 *
 * @author 王丹
 * @since 2018-02-04
 */
@Transactional
@Service
public class WhiteUserService extends AbstractService{

    @Autowired
    private WhiteUserDao whiteUserDao;

    public List<WhiteUserDto> queryBymult(SqlParameterDto sqlParameterDto){
        return whiteUserDao.queryBymult(sqlParameterDto);
    }

    public Long queryCountBymult(SqlParameterDto sqlParameterDto){
        return whiteUserDao.queryCountBymult(sqlParameterDto);
    }

    public BaseResponse insert(WhiteUserDto whiteUserDto){
        BaseResponse baseResponse = new BaseResponse(BaseResponse.FAIL, "保存失败");
        int result = whiteUserDao.insert(whiteUserDto);
        if(result > 0){
            baseResponse.setCode(BaseResponse.SUCCESS);
            baseResponse.setMsg("成功");
        }
        return baseResponse;
    }

    public BaseResponse deleteById(Long id){
        BaseResponse baseResponse = new BaseResponse(BaseResponse.FAIL, "删除失败");
        int result =  whiteUserDao.deleteById(id);
        if(result > 0){
            baseResponse.setCode(BaseResponse.SUCCESS);
        }
        return baseResponse;
    }
}
